- Java Date Time Tutorial
- Java System.currentTimeMillis()
- Java Time Measurement
- Java's java.util.Date
- Java's java.sql.Date
- Java's java.sql.Timestamp
- Java's java.util.Calendar and GregorianCalendar
- Java's java.util.TimeZone
- Parsing and Formatting Dates in Java
- Java Instant
- Java Duration
- Java LocalDate
- Java LocalTime
- Java LocalDateTime
- Java ZonedDateTime
- Java DateTimeFormatter
Java's java.sql.Date
Jakob Jenkov |
Java's java.sql.Date class is used in the JDBC API. If you
need to set a date on a java.sql.PreparedStatement or get a date
from a java.sql.ResultSet, you will interact with
java.sql.Date.
Actually, java.sql.Date extends
java.util.Date, so anything you can
do with a java.util.Date you can also do with a java.sql.Date.
Check out java.util.Date for more details.
Here is how to instantiate a java.sql.Date
long time = System.currentTimeMillis(); java.sql.Date date = new java.sql.Date(time);
The biggest difference between java.sql.Date and java.util.Date
is that the java.sql.Date only keeps the date, not the time, of the date
it represents. So, for instance, if you create a java.sql.Date using
the date and time 2009-12-24 23:20, then the time (23:20)
would be cut off. If you need to keep the time, use a java.sql.Timestamp
instead.
| Tweet | |
Jakob Jenkov | |







